<template>
  <div id="app">
      <h1>Vue Router Demo</h1>
      <hr>
      <div class="wrapper">
        <!--路由query传操，为主使用对象的方式
         1.to属性要用v-bind进行动态绑定
         2.对象中的要具有query属性，这个query属性还是一个对象
        -->
          <div class="list">
              <router-link class="item" :to="{
                  path:'/home',   
                  query:{
                    msg:messageList[0],
                  }
              }">去Home</router-link>
              <router-link class="item" :to="{
                path:'/about',   
                  query:{
                    msg:messageList[1],
                  }
              }">去About</router-link>
          </div>
          <div class="content">
            <!--路由缓存函数，keep-alive,比如需要缓存对应的HomeView组件
              这里的组件可以使用组件名字
              <keep-alive :include="['HomeView']">
              <router-view></router-view>            
              </keep-alive>
            -->
            <router-view></router-view>            
          </div>
          <hr>
          <HelloWorld :msg="messageList[0]" ></HelloWorld>
      </div>
  </div>
</template>
<script>
import HelloWorld from './components/HelloWorld.vue'
export default {
  name: 'App',
  components: {
    HelloWorld,
  },
  data(){
    return {
      messageList:["hello home","hello about"]
    }
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 0;
}
#app .wrapper{
  display:flex;
}
.wrapper .list{
  background-color: #f5f5f5;
  width: 400px;
  height: 100px;
}
.wrapper .content{
  width: 100%;
  height: 100px;
}
.wrapper .list .item{
  text-decoration: none;
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 50%;
  text-align: left;
  background-color: #f5f5f5;
  border: 1px solid;
  border-radius: 5px;
  line-height: 50px;
}
.active{
  background-color: skyblue;
}
</style>
